{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ba49c2998ed32020",
   "metadata": {},
   "source": [
    "## Building a Dappier AI Recommendations Agent\n",
    "\n",
    "<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/llama-index-integrations/tools/llama-index-tools-dappier/examples/dappier_ai_recommendations.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
    "\n",
    "This tutorial walks through using the LLM tools provided by [Dappier](https://dappier.com/) to allow LLMs to use Dappier's pre-trained, LLM ready RAG models and natural language APIs to ensure factual, up-to-date, responses from premium content providers across key verticals like News, Finance, Sports, Weather, and more.\n",
    "\n",
    "\n",
    "To get started, you will need an [OpenAI API key](https://platform.openai.com/account/api-keys) and a [Dappier API key](https://platform.dappier.com/profile/api-keys)\n",
    "\n",
    "We will import the relevant agents and tools and pass them our keys here:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "11992469",
   "metadata": {},
   "source": [
    "## Installation\n",
    "\n",
    "First, install the `llama-index` and `llama-index-tools-dappier` packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: llama-index in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (0.12.25)\n",
      "Requirement already satisfied: llama-index-tools-dappier in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (0.3.0)\n",
      "Requirement already satisfied: llama-index-agent-openai<0.5.0,>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.4.6)\n",
      "Requirement already satisfied: llama-index-cli<0.5.0,>=0.4.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.4.1)\n",
      "Requirement already satisfied: llama-index-core<0.13.0,>=0.12.25 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.12.25)\n",
      "Requirement already satisfied: llama-index-embeddings-openai<0.4.0,>=0.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.3.1)\n",
      "Requirement already satisfied: llama-index-indices-managed-llama-cloud>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.6.9)\n",
      "Requirement already satisfied: llama-index-llms-openai<0.4.0,>=0.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.3.25)\n",
      "Requirement already satisfied: llama-index-multi-modal-llms-openai<0.5.0,>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.4.3)\n",
      "Requirement already satisfied: llama-index-program-openai<0.4.0,>=0.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.3.1)\n",
      "Requirement already satisfied: llama-index-question-gen-openai<0.4.0,>=0.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.3.0)\n",
      "Requirement already satisfied: llama-index-readers-file<0.5.0,>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.4.6)\n",
      "Requirement already satisfied: llama-index-readers-llama-parse>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (0.4.0)\n",
      "Requirement already satisfied: nltk>3.8.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index) (3.9.1)\n",
      "Requirement already satisfied: dappier<0.4.0,>=0.3.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-tools-dappier) (0.3.3)\n",
      "Requirement already satisfied: asyncio<4.0.0,>=3.4.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (3.4.3)\n",
      "Requirement already satisfied: httpx<0.29.0,>=0.23.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (0.28.1)\n",
      "Requirement already satisfied: pydantic<3.0.0,>=1.9 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (2.10.6)\n",
      "Requirement already satisfied: openai>=1.14.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.66.5)\n",
      "Requirement already satisfied: PyYAML>=6.0.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (6.0.2)\n",
      "Requirement already satisfied: SQLAlchemy>=1.4.49 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.25->llama-index) (2.0.39)\n",
      "Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (3.11.14)\n",
      "Requirement already satisfied: dataclasses-json in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (0.6.7)\n",
      "Requirement already satisfied: deprecated>=1.2.9.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (1.2.18)\n",
      "Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (1.0.8)\n",
      "Requirement already satisfied: filetype<2.0.0,>=1.2.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (1.2.0)\n",
      "Requirement already satisfied: fsspec>=2023.5.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (2025.3.0)\n",
      "Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (1.6.0)\n",
      "Requirement already satisfied: networkx>=3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (3.2.1)\n",
      "Requirement already satisfied: numpy in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (2.0.2)\n",
      "Requirement already satisfied: pillow>=9.0.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (11.1.0)\n",
      "Requirement already satisfied: requests>=2.31.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (2.32.3)\n",
      "Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.2.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (9.0.0)\n",
      "Requirement already satisfied: tiktoken>=0.3.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (0.9.0)\n",
      "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (4.67.1)\n",
      "Requirement already satisfied: typing-extensions>=4.5.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (4.12.2)\n",
      "Requirement already satisfied: typing-inspect>=0.8.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (0.9.0)\n",
      "Requirement already satisfied: wrapt in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-core<0.13.0,>=0.12.25->llama-index) (1.17.2)\n",
      "Requirement already satisfied: llama-cloud<0.2.0,>=0.1.13 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-indices-managed-llama-cloud>=0.4.0->llama-index) (0.1.14)\n",
      "Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (4.13.3)\n",
      "Requirement already satisfied: pandas in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.2.3)\n",
      "Requirement already satisfied: pypdf<6.0.0,>=5.1.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (5.4.0)\n",
      "Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (0.0.26)\n",
      "Requirement already satisfied: llama-parse>=0.5.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-index-readers-llama-parse>=0.4.0->llama-index) (0.6.4.post1)\n",
      "Requirement already satisfied: click in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from nltk>3.8.1->llama-index) (8.1.8)\n",
      "Requirement already satisfied: joblib in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from nltk>3.8.1->llama-index) (1.4.2)\n",
      "Requirement already satisfied: regex>=2021.8.3 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from nltk>3.8.1->llama-index) (2024.11.6)\n",
      "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (2.6.1)\n",
      "Requirement already satisfied: aiosignal>=1.1.2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (1.3.2)\n",
      "Requirement already satisfied: async-timeout<6.0,>=4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (5.0.1)\n",
      "Requirement already satisfied: attrs>=17.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (25.3.0)\n",
      "Requirement already satisfied: frozenlist>=1.1.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (1.5.0)\n",
      "Requirement already satisfied: multidict<7.0,>=4.5 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (6.2.0)\n",
      "Requirement already satisfied: propcache>=0.2.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (0.3.0)\n",
      "Requirement already satisfied: yarl<2.0,>=1.17.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.25->llama-index) (1.18.3)\n",
      "Requirement already satisfied: soupsieve>1.2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.6)\n",
      "Requirement already satisfied: anyio in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (4.9.0)\n",
      "Requirement already satisfied: certifi in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (2025.1.31)\n",
      "Requirement already satisfied: httpcore==1.* in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (1.0.7)\n",
      "Requirement already satisfied: idna in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (3.10)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from httpcore==1.*->httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (0.14.0)\n",
      "Requirement already satisfied: llama-cloud-services>=0.6.4 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-parse>=0.5.0->llama-index-readers-llama-parse>=0.4.0->llama-index) (0.6.5)\n",
      "Requirement already satisfied: distro<2,>=1.7.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.9.0)\n",
      "Requirement already satisfied: jiter<1,>=0.4.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (0.9.0)\n",
      "Requirement already satisfied: sniffio in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.3.1)\n",
      "Requirement already satisfied: annotated-types>=0.6.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from pydantic<3.0.0,>=1.9->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.27.2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from pydantic<3.0.0,>=1.9->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (2.27.2)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.25->llama-index) (3.4.1)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.25->llama-index) (2.3.0)\n",
      "Requirement already satisfied: greenlet!=0.4.17 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.25->llama-index) (3.1.1)\n",
      "Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from typing-inspect>=0.8.0->llama-index-core<0.13.0,>=0.12.25->llama-index) (1.0.0)\n",
      "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from dataclasses-json->llama-index-core<0.13.0,>=0.12.25->llama-index) (3.26.1)\n",
      "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.9.0.post0)\n",
      "Requirement already satisfied: pytz>=2020.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2025.1)\n",
      "Requirement already satisfied: tzdata>=2022.7 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2025.1)\n",
      "Requirement already satisfied: exceptiongroup>=1.0.2 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from anyio->httpx<0.29.0,>=0.23.0->dappier<0.4.0,>=0.3.3->llama-index-tools-dappier) (1.2.2)\n",
      "Requirement already satisfied: python-dotenv<2.0.0,>=1.0.1 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from llama-cloud-services>=0.6.4->llama-parse>=0.5.0->llama-index-readers-llama-parse>=0.4.0->llama-index) (1.0.1)\n",
      "Requirement already satisfied: packaging>=17.0 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.13.0,>=0.12.25->llama-index) (24.2)\n",
      "Requirement already satisfied: six>=1.5 in /Users/amaan/Library/Caches/pypoetry/virtualenvs/llama-index-yhiCGw8g-py3.10/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (1.17.0)\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip install llama-index llama-index-tools-dappier"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7f3a766",
   "metadata": {},
   "source": [
    "## Setup API keys\n",
    "\n",
    "You'll need to set up your API keys for OpenAI and Dappier."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59886322",
   "metadata": {},
   "source": [
    "You can go to [here](https://platform.openai.com/settings/organization/api-keys) to get API Key from Open AI."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5316e0f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from getpass import getpass\n",
    "\n",
    "# Prompt for the API key securely\n",
    "openai_api_key = getpass(\"Enter your API key: \")\n",
    "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40347147",
   "metadata": {},
   "source": [
    "You can go to [here](https://platform.dappier.com/profile/api-keys) to get API Key from Dappier with **free** credits."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf4fe7bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Prompt for the Dappier API key securely\n",
    "dappier_api_key = getpass(\"Enter your API key: \")\n",
    "os.environ[\"DAPPIER_API_KEY\"] = dappier_api_key"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e7f73566",
   "metadata": {},
   "source": [
    "## Setup Dappier Tool\n",
    "\n",
    "Initialize the Dappier Real-Time Search Tool, convert it to a tool list."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b0877f51a351135",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "get_sports_news_recommendations\n",
      "get_lifestyle_news_recommendations\n",
      "get_iheartdogs_recommendations\n",
      "get_iheartcats_recommendations\n",
      "get_greenmonster_recommendations\n",
      "get_wishtv_recommendations\n",
      "get_nine_and_ten_news_recommendations\n"
     ]
    }
   ],
   "source": [
    "from llama_index.tools.dappier import (\n",
    "    DappierAIRecommendationsToolSpec,\n",
    ")\n",
    "\n",
    "dappier_tool = DappierAIRecommendationsToolSpec()\n",
    "\n",
    "dappier_tool_list = dappier_tool.to_tool_list()\n",
    "for tool in dappier_tool_list:\n",
    "    print(tool.metadata.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "10363da6",
   "metadata": {},
   "source": [
    "## Usage\n",
    "\n",
    "We've imported our OpenAI agent, set up the api key, and initialized our tool. Let's test out the tool before setting up our Agent.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "427a81ad",
   "metadata": {},
   "source": [
    "### Sports News\n",
    "\n",
    "Real-time news, updates, and personalized content from top sports sources like Sportsnaut, Forever Blueshirts, Minnesota Sports Fan, LAFB Network, Bounding Into Sports, and Ringside Intel.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c2d1e7865b0301f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: Letting Larson be Larson and other observations from NASCAR Homestead\n",
      "Author: Matt Weaver\n",
      "Published on: Mon, 24 Mar 2025 01:17:16 +0000\n",
      "Source: Sportsnaut (sportsnaut.com)\n",
      "URL: https://sportsnaut.com/letting-larson-be-larson-and-other-observations-from-nascar-homestead/\n",
      "Image URL: https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/NASCAR-Straight-Talk-Wireless-400-25750368-1180x787_.jpg?width=428&height=321\n",
      "Summary: In the recent NASCAR race at Homestead, crew chief Cliff Daniels adopted a hands-off approach with Kyle Larson, allowing him to navigate the race independently. This strategy reflects their strong relationship built on trust, enabling Larson to perform at his best despite facing challenges during the race. Meanwhile, Alex Bowman, currently third in the standings, is under pressure regarding his future with Hendrick Motorsports, but team vice chairman Jeff Gordon expressed support for him and crew chief Blake Harris, emphasizing the importance of teamwork and communication.\n",
      "\n",
      "The race also showcased the competitive nature of the drivers, with Bubba Wallace achieving a top-10 finish and expressing frustration over racing dynamics. Other drivers like Ryan Blaney and Denny Hamlin faced their own challenges but remain optimistic about future performances. The event highlighted ongoing tensions between drivers and NASCAR officials, particularly regarding the new car model's impact on performance. Overall, the race underscored the significance of adaptability and resilience in the competitive NASCAR environment.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: Los Angeles Rams Mock Draft 5.0, Including Shocking Offensive Line Solution\n",
      "Author: Jacob Beadles\n",
      "Published on: Mon, 24 Mar 2025 00:59:31 +0000\n",
      "Source: LAFB Network (www.lafbnetwork.com)\n",
      "URL: https://www.lafbnetwork.com/nfl/la-rams/la-rams-news/los-angeles-rams-draft-5-0-mock-draft/\n",
      "Image URL: https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/NFL-Carolina-Panthers-at-Los-Angeles-Rams-19245828_.jpg?width=428&height=321\n",
      "Summary: The article outlines the Los Angeles Rams' strategy for the 2025 NFL Draft, emphasizing their need to strengthen their roster with eight projected picks. The Rams are expected to prioritize offensive line help, starting with Grey Zabel, an offensive lineman from North Dakota State, to protect their quarterback. Additionally, they are considering Harold Fannin Jr., a tight end from Bowling Green, and Tez Johnson, a wide receiver from Oregon, to enhance their offensive capabilities.\n",
      "\n",
      "Furthermore, the Rams plan to address their defense with a fourth-round pick of Jack Kiser, a linebacker from Notre Dame, known for his leadership and impressive stats. The mock draft also includes selections for a quarterback, running back, defensive back, and another offensive lineman in the later rounds. Overall, the Rams aim to acquire young talent to improve their competitiveness in the upcoming season.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Las Vegas Raiders Mock Draft 1.0, Including 3rd Round WR Steal\n",
      "Author: Jacob Beadles\n",
      "Published on: Mon, 24 Mar 2025 00:38:24 +0000\n",
      "Source: LAFB Network (www.lafbnetwork.com)\n",
      "URL: https://www.lafbnetwork.com/nfl/raiders/raiders-news/las-vegas-raiders-draft-1-0-mock-draft/\n",
      "Image URL: https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/NFL-Las-Vegas-Raiders-at-Los-Angeles-Rams-24543345_.jpg?width=428&height=321\n",
      "Summary: The article outlines the Las Vegas Raiders' strategy for the 2025 NFL Draft, emphasizing their need to enhance their roster with nine picks, particularly focusing on their 6th overall selection. The mock draft suggests selecting Ashton Jeanty, a standout running back from Boise State, who is compared to NFL star Alvin Kamara due to his impressive college stats. The article argues that Jeanty's potential impact on the Raiders' offense justifies the risk of drafting a running back early.\n",
      "\n",
      "Additionally, the Raiders are advised to consider Nic Scourton, a defensive lineman from Texas A&M, in the second round, despite a disappointing final college season. Scourton's versatility and pass-rushing skills could significantly strengthen the Raiders' defense. The article also mentions other potential picks, including cornerback Darien Porter and defensive lineman Aeneas Peebles, aimed at establishing a new defensive identity for the team. Overall, the mock draft provides insights into how the Raiders can strategically build a competitive team.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_sports_news_recommendations(\n",
    "        query=\"latest sports news\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa77510d",
   "metadata": {},
   "source": [
    "### Lifestyle News\n",
    "\n",
    "Real-time updates, analysis, and personalized content from top sources like The Mix, Snipdaily, Nerdable, and Familyproof."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "79716cc2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: How to Cook Perfect Chicken Breasts in the Slow Cooker\n",
      "Author: Hetti Misenti\n",
      "Published on: Sun, 23 Mar 2025 17:02:05 +0000\n",
      "Source: Family Proof (www.familyproof.com)\n",
      "URL: https://www.familyproof.com/lifestyle/food-drink/cook-perfect-chicken-breasts-in-slow-cooker/\n",
      "Image URL: https://images.dappier.com/dm_01j0q82s4bfjmsqkhs3ywm3x6y/how-to-cook-chicken-in-the-slow-cooker_.jpg?width=428&height=321\n",
      "Summary: The article outlines a straightforward recipe for preparing tender and juicy chicken breasts in a slow cooker, requiring just 15 minutes of prep and 3 hours of cooking time. It highlights the use of a flavorful blend of herbs and spices, making the chicken versatile for various meals like salads, wraps, or sides.\n",
      "\n",
      "Additionally, the article features a video demonstration and detailed step-by-step instructions to guide readers through the cooking process. It also suggests related content, including other recipes and food insights, aimed at helping home cooks effortlessly achieve perfectly cooked chicken breasts.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: Gene Hackman’s One Major Mistake Is Revealed After He’s Found Dead With His Wife And Dog\n",
      "Author: James Conrad\n",
      "Published on: Sun, 23 Mar 2025 16:02:00 +0000\n",
      "Source: TheMix.net (www.themix.net)\n",
      "URL: https://www.themix.net/celebrity/celebrity-news/gene-hackmans-one-major-mistake-is-revealed-after-hes-found-dead-with-his-wife-and-dog/\n",
      "Image URL: https://images.dappier.com/dm_01j0q82s4bfjmsqkhs3ywm3x6y/Gene-Hackman-10_.jpg?width=428&height=321\n",
      "Summary: Gene Hackman, the renowned actor, was found dead at 95 alongside his wife, Betsy Arakawa, and their dog. Their deaths have raised concerns about Hackman's estate planning, as he had not updated his living trust's list of trustees, all of whom had passed away. This oversight complicates the distribution of his estimated $80 million fortune, which he intended for Arakawa, who likely died shortly before him from Hantavirus.\n",
      "\n",
      "Following their deaths, Avalon Trust, LLC was appointed as the temporary trustee to manage Hackman's estate. Estate planning attorney Laura Cowan emphasized the importance of regularly updating estate plans, as outdated documents can lead to legal challenges. The couple's 20-year-old will may not reflect their current wishes, particularly regarding asset distribution after their simultaneous deaths. The tragic circumstances surrounding their passing have been difficult for their family and friends, highlighting the need for careful estate management.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Weeknight Comfort: Quick Loaded Baked Potato Soup Recipe\n",
      "Author: Hetti Misenti\n",
      "Published on: Sun, 23 Mar 2025 01:08:31 +0000\n",
      "Source: Family Proof (www.familyproof.com)\n",
      "URL: https://www.familyproof.com/lifestyle/food-drink/loaded-baked-potato-soup/\n",
      "Image URL: https://images.dappier.com/dm_01j0q82s4bfjmsqkhs3ywm3x6y/Zight-2025-03-22-at-8.46.34-PM-scaled_.jpg?width=428&height=321\n",
      "Summary: The article provides a recipe for a comforting loaded baked potato soup, designed to replicate the flavors of a traditional baked potato in a creamy, spoonable form. It includes tender potato chunks, melted cheese, crispy bacon, green onions, and a dollop of sour cream, making it a flavorful dish.\n",
      "\n",
      "This easy-to-make soup is perfect for cold evenings, offering warmth and comfort for families. With minimal effort required, it promises to deliver the satisfying experience of a loaded baked potato, making it an ideal choice for a cozy family meal.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_lifestyle_news_recommendations(\n",
    "        query=\"latest lifestyle updates\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16f19d9b",
   "metadata": {},
   "source": [
    "### iHeartDogs Articles\n",
    "\n",
    "A dog care expert with access to articles on health, behavior, lifestyle, grooming, ownership, and more."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f9326445",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: 13 Unforgettable Moments That Prove Your Dog’s Love Never Dies\n",
      "Author: Arlene Divina\n",
      "Published on: Fri, 21 Mar 2025 23:33:19 +0000\n",
      "Source: iHeartDogs.com (iheartdogs.com)\n",
      "URL: https://iheartdogs.com/unforgettable-moments-that-prove-your-dogs-love-never-dies/\n",
      "Image URL: https://images.dappier.com/dm_01j1sz8t3qe6v9g8ad102kvmqn/shutterstock_2037608441_.png?width=428&height=321\n",
      "Summary: The article explores the profound bond between dogs and their owners, highlighting the enduring love and companionship that dogs provide, even after they have passed away. It emphasizes the joy and comfort dogs bring, showcasing their instinctive ability to sense their owner's emotions and offer unwavering support. Memories of affectionate moments, such as enthusiastic greetings and quiet companionship, remain cherished, illustrating how these experiences leave a lasting impact.\n",
      "\n",
      "Additionally, the piece addresses the emotional toll of losing a pet, reassuring readers that their love and memories continue to resonate. It encourages honoring pets through acts of kindness, like creating a Rainbow Bridge listing to support shelter dogs, reinforcing the legacy of love that pets impart. Ultimately, the article celebrates the lasting connection between dogs and their owners, affirming that their love never truly dies.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: 11 Snarky Dog Breeds That Would Totally Fit In At The Golden Girls House\n",
      "Author: Ejay Camposano\n",
      "Published on: Fri, 21 Mar 2025 23:13:37 +0000\n",
      "Source: iHeartDogs.com (iheartdogs.com)\n",
      "URL: https://iheartdogs.com/snarky-dog-breeds-that-would-totally-fit-in-at-the-golden-girls-house/\n",
      "Image URL: https://images.dappier.com/dm_01j1sz8t3qe6v9g8ad102kvmqn/shutterstock_2254275373-scaled-e1742598498424_.jpg?width=428&height=321\n",
      "Summary: The article humorously imagines how various dog breeds would fit into the lively household of \"The Golden Girls,\" drawing parallels between the breeds' personalities and the show's iconic characters. Breeds like the Pekingese, Chihuahua, and Scottish Terrier embody the sass and wit of characters like Blanche, Sophia, and Dorothy, respectively. Other breeds, such as Poodles and Shiba Inus, also reflect the show's humor and dynamics, showcasing their unique traits that would contribute to the household's entertaining chaos.\n",
      "\n",
      "Additionally, the article highlights breeds like Dachshunds, French Bulldogs, and Afghan Hounds, each representing different aspects of the characters' personalities. It playfully suggests that if these dogs were part of the Golden Girls' ensemble, their interactions would mirror the show's comedic essence. The piece concludes with a whimsical notion that these dogs would demand their own trailers if they starred in a sitcom, emphasizing their larger-than-life personas.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: 15 Dog Breeds That Would Be The Best Companions In Red Dead Redemption\n",
      "Author: Ejay Camposano\n",
      "Published on: Fri, 21 Mar 2025 23:11:11 +0000\n",
      "Source: iHeartDogs.com (iheartdogs.com)\n",
      "URL: https://iheartdogs.com/dog-breeds-that-would-be-the-best-companions-in-red-dead-redemption/\n",
      "Image URL: https://images.dappier.com/dm_01j1sz8t3qe6v9g8ad102kvmqn/shutterstock_2156101743-1_.png?width=428&height=321\n",
      "Summary: The article discusses various dog breeds that would make excellent companions in the video game \"Red Dead Redemption,\" each suited for different roles in the Wild West. Breeds like the Australian Cattle Dog and Bloodhound offer practical skills such as herding and tracking, while others like the Basset Hound and Irish Wolfhound provide companionship and protection. The inclusion of these dogs would enhance gameplay, offering players loyal allies for both adventure and quieter moments.\n",
      "\n",
      "Additionally, the article highlights the unique traits of breeds like the Siberian Husky, American Pit Bull Terrier, and Newfoundland, each contributing to the cowboy experience in their own way. The Newfoundland's water-rescue abilities and the Irish Wolfhound's gentle yet protective nature exemplify the ideal canine companions for cowboys. The author expresses hope for the addition of dog companions in future updates, suggesting it could significantly enrich the gaming experience.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_iheartdogs_recommendations(\n",
    "        query=\"dog care tips\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c39a3b2d",
   "metadata": {},
   "source": [
    "### iHeartCats Articles\n",
    "\n",
    "A cat care expert with access to articles on health, behavior, lifestyle, grooming, ownership, and more."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e9373aab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: 7 Reasons Your Cat Is Always by Your Side\n",
      "Author: Clarisse Jelle\n",
      "Published on: Fri, 21 Mar 2025 15:55:06 +0000\n",
      "Source: iHeartCats.com (iheartcats.com)\n",
      "URL: https://iheartcats.com/reasons-your-cat-is-always-by-your-side/\n",
      "Image URL: https://images.dappier.com/dm_01j1sza0h7ekhaecys2p3y0vmj/tabby-cat-with-blanket_.jpg?width=428&height=321\n",
      "Summary: Cats that stay close to their owners often do so as a sign of affection and trust. They view their humans as sources of comfort and security, thriving on the stability that companionship provides. This clinginess can also stem from their territorial instincts, as they want to monitor their environment and ensure safety. \n",
      "\n",
      "Additionally, cats may seek interaction when feeling neglected or during changes in routine. Their behavior, such as following you or seeking comfort during stressful situations, highlights a deep emotional bond. Unlike dogs, cats express love in subtler ways, making their companionship a unique and heartfelt form of affection.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: 15 Things Your Cat Does to Make You Feel Special\n",
      "Author: Clarisse Jelle\n",
      "Published on: Fri, 21 Mar 2025 15:53:37 +0000\n",
      "Source: iHeartCats.com (iheartcats.com)\n",
      "URL: https://iheartcats.com/things-your-cat-does-to-make-you-feel-special/\n",
      "Image URL: https://images.dappier.com/dm_01j1sza0h7ekhaecys2p3y0vmj/spoiled-cat-no_.jpg?width=428&height=321\n",
      "Summary: Cats express their affection in various unique ways, despite their independent nature. Behaviors such as slow blinking, headbutting, and bringing gifts signify trust and a sense of belonging. Following you around and purring indicate their enjoyment of your company and comfort in your presence. Additionally, actions like kneading and rolling onto their backs show vulnerability and security, reinforcing the bond between you and your feline friend.\n",
      "\n",
      "Understanding these affectionate behaviors can deepen your relationship with your cat. From gentle purring to playful antics, each gesture reflects their love and appreciation for you as their favorite human. Recognizing these signs not only enhances your connection but also allows you to appreciate the special ways your cat communicates their feelings.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Top 13 Cat Breeds That Are Masters of Relaxation\n",
      "Author: Clarisse Jelle\n",
      "Published on: Fri, 21 Mar 2025 15:50:47 +0000\n",
      "Source: iHeartCats.com (iheartcats.com)\n",
      "URL: https://iheartcats.com/cat-breeds-masters-relaxation/\n",
      "Image URL: https://images.dappier.com/dm_01j1sza0h7ekhaecys2p3y0vmj/affection_.jpg?width=428&height=321\n",
      "Summary: The article discusses various cat breeds that excel in relaxation and companionship, making them ideal for low-maintenance pet owners. Breeds like Ragdolls, British Shorthairs, and Persians are highlighted for their calm and affectionate natures, often preferring cozy environments and gentle interactions. Other breeds, such as Maine Coons and Russian Blues, also embody tranquility while enjoying human companionship, making them perfect for serene households.\n",
      "\n",
      "Additionally, the article mentions the Himalayan cat, known for its fluffy appearance and affectionate demeanor, which thrives in quiet settings. These breeds not only provide comfort but also serve as excellent stress-relief pets, encouraging a slower pace of life and reminding owners to appreciate moments of tranquility.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_iheartcats_recommendations(\n",
    "        query=\"cat care advice\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e69b1986",
   "metadata": {},
   "source": [
    "### GreenMonster Articles\n",
    "\n",
    "A helpful guide to making conscious and compassionate choices that help people, animals, and the planet.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5192621",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: David Suzuki Warns We Are on a Path to Environmental Self-Destruction\n",
      "Author: Nicholas Vincent\n",
      "Published on: Mon, 24 Mar 2025 07:46:23 +0000\n",
      "Source: One Green Planet (www.onegreenplanet.org)\n",
      "URL: https://www.onegreenplanet.org/news/david-suzuki-warns-we-are-on-a-path-to-environmental-self-destruction/\n",
      "Image URL: https://images.dappier.com/dm_01j5xy9w5sf49bm6b1prm80m27/shutterstock_349246163-scaled-e1742732298867_.jpg?width=428&height=321\n",
      "Summary: David Suzuki warns that humanity is on a perilous path toward environmental self-destruction, emphasizing the urgent need for collective action against climate change. He highlights the immediate consequences of inaction, such as extreme weather and biodiversity loss, and calls for a shift in mindset prioritizing sustainability over short-term economic gains. Suzuki advocates for grassroots movements and policy changes, urging individuals to take responsibility for their environmental impact and push for systemic changes to ensure a healthier planet for future generations.\n",
      "\n",
      "The article encourages readers to engage in sustainable practices, such as reducing meat consumption and supporting ethical consumerism. It underscores the importance of individual actions, like recycling and supporting local economies, while also promoting collective responsibility in addressing environmental challenges. Suzuki's holistic approach incorporates Indigenous wisdom, emphasizing humanity's interconnectedness with nature. The message is clear: immediate action is essential to avert ecological disaster, and every effort counts in the fight for a livable planet.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: USDA Halts $500 Million in Food Bank Deliveries as Food Prices Stay High\n",
      "Author: Nicholas Vincent\n",
      "Published on: Mon, 24 Mar 2025 07:45:14 +0000\n",
      "Source: One Green Planet (www.onegreenplanet.org)\n",
      "URL: https://www.onegreenplanet.org/news/usda-halts-500-million-in-food-bank-deliveries-as-food-prices-stay-high/\n",
      "Image URL: https://images.dappier.com/dm_01j5xy9w5sf49bm6b1prm80m27/shutterstock_2471119761-1-scaled-e1742740486589_.jpg?width=428&height=321\n",
      "Summary: The article discusses the USDA's suspension of $500 million in food bank deliveries, a decision that exacerbates food insecurity in the U.S. amid rising prices. Major food banks, such as the Central California Food Bank and the Capital Area Food Bank, report significant losses due to canceled deliveries, impacting their ability to provide essential items to vulnerable populations. The USDA cites the unsustainable nature of pandemic-era assistance programs as the reason for this pause, raising concerns about the future of food support.\n",
      "\n",
      "As food banks struggle to adapt, the article emphasizes the urgent need for community support through donations and encourages individuals to consider plant-based contributions, which can be more cost-effective and sustainable. It also calls for engagement in environmental activism, highlighting the importance of individual actions in addressing broader social and environmental issues. Overall, the piece underscores the critical role of food banks and the necessity for renewed efforts to ensure they can continue serving those in need.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Plant-Based Cold and Flu Relief Could Change the Way We Treat Illness\n",
      "Author: Nicholas Vincent\n",
      "Published on: Mon, 24 Mar 2025 07:44:57 +0000\n",
      "Source: One Green Planet (www.onegreenplanet.org)\n",
      "URL: https://www.onegreenplanet.org/news/plant-based-cold-and-flu-relief-could-change-the-way-we-treat-illness/\n",
      "Image URL: https://images.dappier.com/dm_01j5xy9w5sf49bm6b1prm80m27/shutterstock_2019676034-scaled-e1742741209866_.jpg?width=428&height=321\n",
      "Summary: The article explores the potential of plant-based remedies, particularly BioVanta, in providing relief from cold and flu symptoms, advocating for a shift from traditional pharmaceuticals to natural solutions. It emphasizes the benefits of incorporating whole foods, herbs, and spices known for their immune-boosting properties into our diets, especially during cold and flu season. BioVanta, developed by Dr. Nazlie Latefi, targets inflammation rather than just symptoms, showing no major side effects in clinical trials.\n",
      "\n",
      "Additionally, the article promotes sustainable living practices and encourages readers to support environmental initiatives. It highlights the interconnectedness of health and animal welfare, urging individuals to consider plant-based options and engage in eco-friendly behaviors. By embracing natural remedies and sustainable choices, the article advocates for improved health outcomes and a more compassionate approach to both personal well-being and the planet's health.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_greenmonster_recommendations(\n",
    "        query=\"sustainable living\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "054a6dcc",
   "metadata": {},
   "source": [
    "### WISH-TV News\n",
    "\n",
    "Politics, breaking news, multicultural news, Hispanic language content, Entertainment, Health, Education, and many more."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3efca541",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: Bright and breezy Monday, rain chances return Tuesday | Mar. 24, 2025\n",
      "Author: Marcus Bailey\n",
      "Published on: Mon, 24 Mar 2025 08:55:10 +0000\n",
      "Source: Indianapolis News | Indiana Weather | Indiana Traffic | WISH-TV | (www.wishtv.com)\n",
      "URL: https://www.wishtv.com/weather/bright-and-breezy-monday-rain-chances-return-tuesday-mar-24-2025/\n",
      "Image URL: https://images.dappier.com/dm_01jagy9nqaeer9hxx8z1sk1jx6/5-DAY-POPS_.jpg?width=428&height=321\n",
      "Summary: This week in Indianapolis will begin with bright and breezy weather, featuring sunny skies and wind gusts up to 40 mph, with high temperatures in the mid-50s. As the week progresses, rain chances will increase, starting with cloudy conditions and light showers on Tuesday, continuing into early Wednesday morning before improving by the afternoon. \n",
      "\n",
      "The weekend is expected to bring warmer temperatures and widespread showers, with potential thunderstorms and rainfall amounts exceeding 1.5 to 2 inches, raising minor flooding concerns. Following the weekend storm system, a significant drop in temperatures is anticipated at the start of April, but a return to above-average temperatures is expected shortly thereafter.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: Indiana postal service workers rally against privatization efforts\n",
      "Author: Kyla Russell\n",
      "Published on: Mon, 24 Mar 2025 02:48:04 +0000\n",
      "Source: Indianapolis News | Indiana Weather | Indiana Traffic | WISH-TV | (www.wishtv.com)\n",
      "URL: https://www.wishtv.com/news/i-team-8/indiana-postal-service-workers-rally-against-privatization-efforts/\n",
      "Image URL: https://images.dappier.com/dm_01jagy9nqaeer9hxx8z1sk1jx6/fight-like-hell-campaign_.jpg?width=428&height=321\n",
      "Summary: On Sunday, postal workers in Indiana and across the U.S. rallied against privatization efforts of the U.S. Postal Service (USPS) as part of the National Association of Letter Carriers' \"Fight Like Hell\" campaign. Hundreds gathered to express concerns that privatization would threaten their jobs and the reliability of mail delivery, particularly in rural areas. Union leaders emphasized that such changes could undermine the USPS's legal mandate to deliver mail six days a week.\n",
      "\n",
      "The protests were fueled by President Trump's hints at privatization, especially regarding the appointment of Howard Lutnick as commerce secretary to oversee USPS operations. With the USPS facing a $9.5 billion loss last fiscal year, workers fear that proposed cuts could lead to job losses and increased shipping costs, exacerbating inflation. The article underscores the potential negative impacts of privatization on service quality and accessibility for millions of Americans.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Kyle Larson wins Cup Series at Homestead, finishes one race shy of triple-header sweep\n",
      "Author: ALANIS THAMES AP Sports Writer\n",
      "Published on: Mon, 24 Mar 2025 01:39:00 +0000\n",
      "Source: Indianapolis News | Indiana Weather | Indiana Traffic | WISH-TV | (www.wishtv.com)\n",
      "URL: https://www.wishtv.com/sports/motorsports/kyle-larson-wins-cup-series-at-homestead-finishes-one-race-shy-of-triple-header-sweep/\n",
      "Image URL: https://images.dappier.com/dm_01jagy9nqaeer9hxx8z1sk1jx6/Kyle-Larson-wins-Cup-Series-at-Homestead-finishes-one-race-shy-of-triple-header-sweep-e1742780301695_.jpg?width=428&height=321\n",
      "Summary: Kyle Larson achieved his 30th career victory in the NASCAR Cup Series at Homestead-Miami Speedway, overtaking teammate Alex Bowman with six laps remaining. This win, his first of the season and second at Homestead, followed a strong weekend where he also won the Craftsman Truck race and finished fourth in the Xfinity Series. Despite starting in 14th place and facing various challenges, Larson's perseverance paid off, marking a significant emotional victory after previous disappointments at the track.\n",
      "\n",
      "The race featured notable performances, including Alex Bowman's second-place finish and Bubba Wallace's third after leading 56 laps. Ryan Blaney, who led 124 laps, faced engine failure that ended his race prematurely. Additionally, incidents on pit road, including a collision involving Larson, added to the drama. Discussions among drivers about the potential return of Homestead to the postseason highlight its historical significance in NASCAR, with Denny Hamlin advocating for its increased role in future championships.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_wishtv_recommendations(\n",
    "        query=\"latest breaking news\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ff2ede5e",
   "metadata": {},
   "source": [
    "### 9 and 10 News\n",
    "\n",
    "Up-to-date local news, weather forecasts, sports coverage, and community stories for Northern Michigan, including the Cadillac and Traverse City areas."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6217a966",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Result 1:\n",
      "Title: LSSU ready for first ever Elite 8 appearance\n",
      "Author: Jim LeHocky, Jake Boss\n",
      "Published on: Sat, 22 Mar 2025 03:52:29 +0000\n",
      "Source: 9&10 News (www.9and10news.com)\n",
      "URL: https://www.9and10news.com/sports/2025/03/21/lssu-ready-for-first-ever-elite-8-appearance/\n",
      "Image URL: https://images.dappier.com/dm_01jhtt138wf1b9j8jwswye99y5/t_81f04f3cc99440d983d3485fa4d871eb_name_file_1920x1080_5400_v4__.jpg?width=428&height=321\n",
      "Summary: Lake Superior State University's men's basketball team has achieved a historic milestone by reaching the Elite 8 of the NCAA Division 2 tournament for the first time. After a tough loss in the GLIAC Championship game, the Lakers have bounced back under the guidance of head coach Steve Hettinga, preparing to face Dallas Baptist University on March 24th.\n",
      "\n",
      "Coach Hettinga commended the team's defensive strategies, which have been crucial in their tournament success. Senior guard Tyson Edmonson, the 2025 Midwest Regional Tournament MVP, has been instrumental, averaging 25 points per game. The Lakers are optimistic as they aim to translate their defensive strengths into offensive success in the upcoming match.\n",
      "Score: None\n",
      "\n",
      "Result 2:\n",
      "Title: Northern Michigan Winter Sports Recap\n",
      "Author: Jake Boss\n",
      "Published on: Sat, 22 Mar 2025 03:52:24 +0000\n",
      "Source: 9&10 News (www.9and10news.com)\n",
      "URL: https://www.9and10news.com/sports/2025/03/21/northern-michigan-winter-sports-recap/\n",
      "Image URL: https://images.dappier.com/dm_01jhtt138wf1b9j8jwswye99y5/t_4d5a94da447b482ea13a2fda12d30bdd_name_file_1920x1080_5400_v4__.jpg?width=428&height=321\n",
      "Summary: The winter sports season in Northern Michigan highlighted significant achievements, particularly in skiing and basketball. The Harbor Springs girls' ski team won the Division 2 state championship, while Traverse City Central's girls reclaimed the Division 1 title. In hockey, Petoskey and Sault Ste. Marie both secured regional championships but were eliminated in the quarterfinals. \n",
      "\n",
      "In basketball, St. Ignace's girls had a standout season with 22 consecutive wins, and Frankfort also performed well, winning a regional title. Despite strong playoff runs, no teams advanced past the quarterfinals. Pickford and Bellaire had notable seasons, but both faced tough losses in the playoffs, showcasing resilience and skill throughout the competitive winter sports season.\n",
      "Score: None\n",
      "\n",
      "Result 3:\n",
      "Title: Grand Traverse Conservation District host Spring Market\n",
      "Author: Megan Huiskens\n",
      "Published on: Fri, 21 Mar 2025 23:25:47 +0000\n",
      "Source: 9&10 News (www.9and10news.com)\n",
      "URL: https://www.9and10news.com/2025/03/21/grand-traverse-conservation-district-host-spring-market/\n",
      "Image URL: https://images.dappier.com/dm_01jhtt138wf1b9j8jwswye99y5/t_9f83383fc663486fb06c9800640d9835_name_file_1920x1080_5400_v4__.jpg?width=428&height=321\n",
      "Summary: The Grand Traverse Conservation District is hosting a Spring Market in Traverse City, Michigan, tomorrow at 2 p.m. at the Boardman River Nature Center. The market will showcase various nature-themed artisans, including local honey producers, and feature the Annual Seedling Sale, allowing attendees to order native plants for their gardens.\n",
      "\n",
      "Miranda Fraley, the Outreach and Giving Coordinator, highlights the significance of planting native species, which support local wildlife and are adapted to the region's ecosystems. The event aims to foster environmental awareness and encourage community participation in conservation initiatives.\n",
      "Score: None\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    dappier_tool.get_nine_and_ten_news_recommendations(\n",
    "        query=\"northern michigan local news\", similarity_top_k=3\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d41fb0d3",
   "metadata": {},
   "source": [
    "### Using the Dappier AI Recommendations tool in an Agent\n",
    "\n",
    "We can create an agent with access to the Dappier AI Recommendations tool start testing it out:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a33051ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "from llama_index.core.agent import FunctionAgent\n",
    "from llama_index.llms.openai import OpenAI\n",
    "\n",
    "agent = FunctionAgent(\n",
    "    tools=dappier_tool_list,\n",
    "    llm=OpenAI(model=\"gpt-4o\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba290fe8f1621839",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "### Latest Sports News\n",
      "1. **NASCAR Homestead Observations**\n",
      "   - **Summary**: Kyle Larson's independent racing strategy at Homestead highlights his strong relationship with crew chief Cliff Daniels. Despite challenges, Larson's adaptability shines. Alex Bowman faces pressure, but Hendrick Motorsports supports him. Bubba Wallace secures a top-10 finish amid racing tensions.\n",
      "   - **Source**: [Sportsnaut](https://sportsnaut.com/letting-larson-be-larson-and-other-observations-from-nascar-homestead/)\n",
      "\n",
      "2. **Los Angeles Rams Mock Draft**\n",
      "   - **Summary**: The Rams focus on strengthening their roster with offensive line help in the 2025 NFL Draft. Key picks include Grey Zabel and Harold Fannin Jr. for offensive enhancement, and Jack Kiser for defense.\n",
      "   - **Source**: [LAFB Network](https://www.lafbnetwork.com/nfl/la-rams/la-rams-news/los-angeles-rams-draft-5-0-mock-draft/)\n",
      "\n",
      "3. **Las Vegas Raiders Draft Strategy**\n",
      "   - **Summary**: The Raiders aim to enhance their roster with nine picks, focusing on Ashton Jeanty, a standout running back, and Nic Scourton for defense. The draft strategy aims to build a competitive team.\n",
      "   - **Source**: [LAFB Network](https://www.lafbnetwork.com/nfl/raiders/raiders-news/las-vegas-raiders-draft-1-0-mock-draft/)\n",
      "\n",
      "4. **Los Angeles Lakers Injury Update**\n",
      "   - **Summary**: Rui Hachimura returns to the Lakers with a knee injury, playing limited minutes. Despite challenges, he contributes significantly, averaging 13.1 points.\n",
      "   - **Source**: [LAFB Network](https://www.lafbnetwork.com/nba/la-lakers/la-lakers-news/los-angeles-lakers-rui-hachimura-injury-70-percent/)\n",
      "\n",
      "5. **Mookie Betts Pulled from Dodgers Lineup**\n",
      "   - **Summary**: Mookie Betts was unexpectedly scratched from the Dodgers' lineup due to health concerns. His recovery is crucial for the team's success.\n",
      "   - **Source**: [LAFB Network](https://www.lafbnetwork.com/mlb/la-dodgers/la-dodgers-news/los-angeles-dodgers-mookie-betts-scratched-freeway-series/)\n",
      "\n",
      "### Latest Lifestyle News\n",
      "1. **Slow Cooker Chicken Recipe**\n",
      "   - **Summary**: A simple recipe for tender chicken breasts using a slow cooker, perfect for various meals. Includes a video demonstration and step-by-step instructions.\n",
      "   - **Source**: [Family Proof](https://www.familyproof.com/lifestyle/food-drink/cook-perfect-chicken-breasts-in-slow-cooker/)\n",
      "\n",
      "2. **Gene Hackman's Estate Planning Oversight**\n",
      "   - **Summary**: Gene Hackman and his wife were found dead, highlighting estate planning issues due to outdated documents. Avalon Trust, LLC manages the estate temporarily.\n",
      "   - **Source**: [TheMix.net](https://www.themix.net/celebrity/celebrity-news/gene-hackmans-one-major-mistake-is-revealed-after-hes-found-dead-with-his-wife-and-dog/)\n",
      "\n",
      "3. **Loaded Baked Potato Soup Recipe**\n",
      "   - **Summary**: A comforting soup recipe replicating baked potato flavors, perfect for cold evenings. Easy to make and family-friendly.\n",
      "   - **Source**: [Family Proof](https://www.familyproof.com/lifestyle/food-drink/loaded-baked-potato-soup/)\n",
      "\n",
      "4. **Contractor Reveals Details About Hackman's Death**\n",
      "   - **Summary**: New details emerge about Gene Hackman's death, emphasizing the emotional impact and awareness of Hantavirus.\n",
      "   - **Source**: [TheMix.net](https://www.themix.net/celebrity/celebrity-news/contractor-who-found-bodies-of-gene-hackman-and-his-wife-reveals-heartbreaking-new-details-about-their-deaths/)\n",
      "\n",
      "5. **Ryan Reynolds' Future Roles**\n",
      "   - **Summary**: Speculation about Ryan Reynolds' future in superhero roles, suggesting characters like Midnighter and Gambit.\n",
      "   - **Source**: [Bounding Into Comics](https://boundingintocomics.com/movies/lists/10-comics-characters-ryan-reynolds-should-play-after-deadpool/)\n",
      "\n",
      "### Breaking News\n",
      "1. **Weather Update for Indianapolis**\n",
      "   - **Summary**: Indianapolis experiences bright weather with rain expected mid-week. The weekend may bring thunderstorms and minor flooding.\n",
      "   - **Source**: [WISH-TV](https://www.wishtv.com/weather/bright-and-breezy-monday-rain-chances-return-tuesday-mar-24-2025/)\n",
      "\n",
      "2. **Indiana Postal Workers Rally**\n",
      "   - **Summary**: Postal workers rally against USPS privatization, fearing job losses and service quality decline.\n",
      "   - **Source**: [WISH-TV](https://www.wishtv.com/news/i-team-8/indiana-postal-service-workers-rally-against-privatization-efforts/)\n",
      "\n",
      "3. **Kyle Larson Wins at Homestead**\n",
      "   - **Summary**: Kyle Larson wins the NASCAR Cup Series at Homestead, marking his 30th career victory.\n",
      "   - **Source**: [WISH-TV](https://www.wishtv.com/sports/motorsports/kyle-larson-wins-cup-series-at-homestead-finishes-one-race-shy-of-triple-header-sweep/)\n",
      "\n",
      "4. **Community Welcomes Boy After Transplant**\n",
      "   - **Summary**: Aiden, a 15-year-old, returns home after a kidney transplant, welcomed by community support.\n",
      "   - **Source**: [WISH-TV](https://www.wishtv.com/news/local-news/boone-county-community-welcomes-boy-home-after-five-year-wait-for-transplant/)\n",
      "\n",
      "5. **Carmel Hosts Swimming World Cup 2025**\n",
      "   - **Summary**: Carmel, Indiana, will host the Swimming World Cup 2025, showcasing its strong swimming tradition.\n",
      "   - **Source**: [WISH-TV](https://www.wishtv.com/sports/carmel-hosts-swimming-world-cup/)\n",
      "\n",
      "### Dog Care Advice\n",
      "1. **Dog's Love Never Dies**\n",
      "   - **Summary**: Explores the enduring bond between dogs and owners, emphasizing the lasting impact of their love and companionship.\n",
      "   - **Source**: [iHeartDogs](https://iheartdogs.com/unforgettable-moments-that-prove-your-dogs-love-never-dies/)\n",
      "\n",
      "2. **Snarky Dog Breeds and The Golden Girls**\n",
      "   - **Summary**: Imagines how various dog breeds would fit into \"The Golden Girls\" household, highlighting their personalities.\n",
      "   - **Source**: [iHeartDogs](https://iheartdogs.com/snarky-dog-breeds-that-would-totally-fit-in-at-the-golden-girls-house/)\n",
      "\n",
      "3. **Dog Breeds for Red Dead Redemption**\n",
      "   - **Summary**: Discusses dog breeds that would make excellent companions in \"Red Dead Redemption,\" enhancing gameplay.\n",
      "   - **Source**: [iHeartDogs](https://iheartdogs.com/dog-breeds-that-would-be-the-best-companions-in-red-dead-redemption/)\n",
      "\n",
      "4. **Dog Breeds and Clean Girl Aesthetic**\n",
      "   - **Summary**: Highlights dog breeds that align with the \"clean girl aesthetic,\" emphasizing minimalism and elegance.\n",
      "   - **Source**: [iHeartDogs](https://iheartdogs.com/dog-breeds-that-are-perfectly-aligned-with-the-clean-girl-aesthetic/)\n",
      "\n",
      "5. **Courageous Dog Breeds as Superheroes**\n",
      "   - **Summary**: Suggests dog breeds that could be cast as superheroes, showcasing their heroic traits.\n",
      "   - **Source**: [iHeartDogs](https://iheartdogs.com/courageous-breeds-that-would-be-cast-in-the-next-big-superhero-movie/)\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    await agent.run(\n",
    "        \"Get latest sports news, lifestyle news, breaking news, dog care advice and summarize it into different sections, with source links.\"\n",
    "    )\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llama-index-yhiCGw8g-py3.10",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
